package com.beiye.drivertransport.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.beiye.drivertransport.R;
import com.beiye.drivertransport.bean.AddittionCourseBean;

/**
 * Created by ky on 2018/6/27.
 */

public class AdditionCourseApt extends ListBaseAdapter<AddittionCourseBean.RowsBean> {

    protected Context context = null;
    public AdditionCourseApt(Context context){
        super(context);
        this.context = context;
    }

    @Override
    public int getLayoutId() {
        return R.layout.course_item_layout1;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        AddittionCourseBean.RowsBean rowsBean = getDataList().get(position);

        ImageView img_course =  holder.getView(R.id.img_course);
        ImageView img_over =  holder.getView(R.id.img_course5);
        TextView tv_studyState = holder.getView(R.id.tv_child4);
        TextView tv_title = holder.getView(R.id.tv_course);
        TextView tv_coursetime = holder.getView(R.id.tv_course2);
        //    TextView tv_num = holder.getView(R.id.tv_course3);
        //   ImageView tv_courseno = holder.getView(R.id.tv_course5);
        //   TextView tv_courseyes = holder.getView(R.id.tv_course6);
        tv_title.setText(rowsBean.getCourseName());
        tv_coursetime.setText("课程时长:"+rowsBean.getReadLength()+"分");
        int finishMark = rowsBean.getFinishMark();
        int havedLength= rowsBean.getHavedLength(); //已阅读时长
        if (finishMark == 0) {

            if (havedLength > 0) {
                tv_studyState.setBackgroundResource(R.drawable.stroke_orange_2);
                tv_studyState.setTextColor(holder.itemView.getResources().getColor(R.color.orange_namesecond));
                tv_studyState.setText("未完成");
            } else {
                tv_studyState.setBackgroundResource(R.drawable.stroke_red_2);
                tv_studyState.setTextColor(holder.itemView.getResources().getColor(R.color.red_gray));
                tv_studyState.setText("去学习");
            }
        } else if (finishMark == 1) {
            tv_studyState.setBackgroundResource(R.drawable.stroke_green_2);
            tv_studyState.setTextColor(holder.itemView.getResources().getColor(R.color.green_gray));
            if (havedLength > 0) {
                tv_studyState.setText("已学习");
            }
        }

//        if(finishMark==0)
//        {
//            img_over.setVisibility(View.VISIBLE);
//            img_over.setImageResource(R.mipmap.wxx);
//        }else if(finishMark==1){
//            img_over.setVisibility(View.VISIBLE);
//            img_over.setImageResource(R.mipmap.yxx);
//        }

        //    tv_num.setText("已读次数:"+rowsBean.getReadNo()+"次");
//        if(rowsBean.getStudyState()==0)
//        {
//
//         //   tv_courseno.setImageResource(R.mipmap.wxx);
//            img_course.setImageResource(R.mipmap.icon_kccs_03);
//        }else if(rowsBean.getStudyState()==1)
//        {
//       //     tv_courseno.setImageResource(R.mipmap.yxx);
//            img_course.setImageResource(R.mipmap.icon_kccs_06);
//        }
//        if(rowsBean.getMrMark()==0)
//        {
//            tv_courseyes.setVisibility(View.INVISIBLE);
//        }else if(rowsBean.getMrMark()==1)
//        {
//            tv_courseyes.setVisibility(View.VISIBLE);
//            tv_courseyes.setText("必学");
//        }



        //   Picasso.with(context).load(Uri.parse(AppInterfaceConfig.getRequestUrl(rowsBean.getTopPicUrl()))).placeholder(R.mipmap.no_data).into(img_course);//加载图片


    }




}